package com.gscitysfy.cus.drain.modules.duty.service.impl;


import com.gscitysfy.cus.drain.modules.duty.service.MoperDutyHolidayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.Date;

/**
 * @author 葛守跃
 * @version 1.0.0
 * @ClassName MoperDutyAutomaticScheduling
 * @Description TODO
 * @creatTime 2022/4/25 17:38
 */
@Configuration
@EnableScheduling
@Slf4j
public class MoperDutyAutomaticScheduling {

    @Resource
    private MoperDutyHolidayService holidayService;

    /**
     * @Scheduled(cron = "0/5 * * * * ?")
     */
    @Scheduled(cron = "0 0 1 28 * ?")
    private void automaticSchedulingTask() {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        holidayService.saveAutoDutyPlan(calendar.get(Calendar.MONTH) + 1 >= 10? (calendar.get(Calendar.MONTH) + 1) + "":"0" + (calendar.get(Calendar.MONTH) + 1),  calendar.get(Calendar.YEAR) + "");
        log.info("定时自动排班：{}: ", LocalDateTime.now());
    }

}
